package test1231.test1;

public class CompanyA {
    String name;
    MemberFather[] memberFather = new MemberFather[100];
    int memberFatherIndex = 0;
    public CompanyA(String name) {
        this.name = name;
    }
    public void add(String name, int money) {
        MemberA member = new MemberA(name, money);
        add(member);
    }

    public void add(MemberFather member) {
            for(int i = 0; i < memberFather.length; i++) {
                if(memberFather[i] == null) {
                    memberFather[memberFatherIndex] = member;
                    memberFatherIndex++;
                    System.out.println(member.getName() + "添加成功");
                    break;
                }
            }
    }

    public double getAllSalary() {
        double sum = 0;
        for(int i = 0; i < memberFather.length; i++){
            if(memberFather[i] != null) {
                sum += memberFather[i].allmoney();
            }
        }
        return sum;
    }
}
